package com.lgl.scsheader.information.controller;

import com.lgl.scsapi.system.model.PageData;
import com.lgl.scsapi.system.model.SysUser;
import com.lgl.scsheader.base.controller.BaseController;
import com.lgl.scsheader.information.service.SameCityFeedbackService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 同城反馈
 */
@Slf4j
@RestController
@RequestMapping(value="/sameCityFeedback")
public class SameCityFeedbackController extends BaseController{
	@Resource(name="sameCityFeedbackService")
	private SameCityFeedbackService sameCityFeedbackService;
	
	//通过条件获取用户反馈信息集合
	@PostMapping(value="listFeedback")
	public Object listFeedback() {
		PageData pd = this.getPageData();
		int pageNo = Integer.parseInt(pd.remove("page").toString()),
		pageSize = Integer.parseInt(pd.remove("rows").toString());
		return sameCityFeedbackService.listUserFeedback(pd,pageNo,pageSize);
	}
	//获取一条反馈信息
	@PostMapping(value="getFeedback")
	public Object getFeedback() {
		String fbId = getRequest().getParameter("fbId");
		return sameCityFeedbackService.findFeedbackById(fbId);
	}
	//处理反馈信息
	@PostMapping(value = "dealFeedback")
	public int dealFeedback() {
		PageData fbPd = getPageData();
		if (!StringUtils.hasText(fbPd.getString("fbId"))){
			return -1;
		}
		SysUser sysUser = getSessionUser();
		fbPd.put("dealPeopleId", sysUser.getUserId());
		return sameCityFeedbackService.editFeedback(fbPd);
	}
}